/**
 * Created by Sean Patrick Floyd (<a
 * href="mailto:sfloyd@mytoys.de">sfloyd@mytoys.de</a>) on 15.06.2010.
 */
package com.google.code.wicket.auth.component.strategy.part;

import org.apache.wicket.Component;

/**
 * A strategy to determine statically if component instantiation is allowed.
 * Designed as a substitute for
 * {@link org.apache.wicket.authorization.IAuthorizationStrategy#isInstantiationAuthorized(Class)
 * IAuthorizationStrategy.isInstantiationAuthorized(..)}.
 */
public interface StaticAuthorizationStrategy {

    /**
     * A {@link StaticAuthorizationStrategy} that always returns true.
     */
    StaticAuthorizationStrategy ALLOW_ALL = new StaticAuthorizationStrategy() {

        @Override
        public <X extends Component> boolean isInstantiationAuthorized(
                final Class<X> componentClass) {
            return true;
        }
    };

    /**
     * Static class based check whether component initialization is allowed.
     * 
     * @param <X>
     *            the component type
     * @param componentClass
     *            the component class
     * @return true if instantiation is allowed
     */
    <X extends Component> boolean isInstantiationAuthorized(
            final Class<X> componentClass);
}
